package com.example.qxfw.jtyb.controller;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.common.entity.yj.DzWarning;
import com.example.qxfw.common.util.DateUtil;
import com.example.qxfw.jtyb.service.DzzhService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import java.util.List;

@ApiIgnore
@Api(tags = "交通预报-地质灾害")
@RestController
@CrossOrigin
@RequestMapping("/dzzh")
public class DzzhController {

    @Autowired
    private DzzhService dzzhService;

    @ApiOperation("根据时间段获取地址灾害表信息")
    @GetMapping("/selectByDatePeriodOfDzWarning")
    public SysResult selectByDatePeriodOfDzWarning(String startTime, String EndTime){
        Date datecharStart = DateUtil.localDateTimeToDate(DateUtil.stringToLocalDateTime(startTime));
        Date datecharEnd = DateUtil.localDateTimeToDate(DateUtil.stringToLocalDateTime(EndTime));
        List<DzWarning> list = dzzhService.selectByDatePeriodOfDzWarning(datecharStart, datecharEnd);
        return SysResult.success(list);
    }
}
